using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ArbtchdtMap : EntityTypeConfiguration<Arbtchdt>
    {
        public ArbtchdtMap()
        {
            // Primary Key
            this.HasKey(t => t.BTCHDET_ID);

            // Properties
            this.Property(t => t.DESC)
                .HasMaxLength(40);

            this.Property(t => t.REFERENCE)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.BATCH)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.ACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.SOURCE)
                .HasMaxLength(2);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Arbtchdt");
            this.Property(t => t.BTCHDET_ID).HasColumnName("BTCHDET_ID");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.AMOUNT).HasColumnName("AMOUNT");
            this.Property(t => t.AMOUNTDOL).HasColumnName("AMOUNTDOL");
            this.Property(t => t.AMOUNTPAT).HasColumnName("AMOUNTPAT");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.REFERENCE).HasColumnName("REFERENCE");
            this.Property(t => t.BATCH).HasColumnName("BATCH");
            this.Property(t => t.ACCT).HasColumnName("ACCT");
            this.Property(t => t.SOURCE).HasColumnName("SOURCE");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.CSTCTRID).HasColumnName("CSTCTRID");

            // Relationships
            this.HasRequired(t => t.Acct1)
                .WithMany(t => t.Arbtchdts)
                .HasForeignKey(d => d.ACCT);
            this.HasRequired(t => t.Arbatch)
                .WithMany(t => t.Arbtchdts)
                .HasForeignKey(d => d.REFERENCE);
            this.HasRequired(t => t.Batchttl)
                .WithMany(t => t.Arbtchdts)
                .HasForeignKey(d => d.BATCH);
            this.HasOptional(t => t.Cstctr)
                .WithMany(t => t.Arbtchdts)
                .HasForeignKey(d => d.CSTCTRID);

        }
    }
}
